<?php
    session_start();
    if (isset($_POST['submit'])){
        if (strtoupper(trim($_POST["code"]))==$_SESSION["code"]){
            echo "验证码输入成功！<br>";
        }else{
            echo "<font color='red'>验证码输入错误！</font><br>";
        }
    }
    echo $_POST["code"];
    echo $_SESSION["code"];

?>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>验证码</title>
        <script>
            function newgdcode(obj,url)
            {
                obj.src=url+'?nowtime='+new Data().getTime();
            }
        </script>
    </head>

    <body>
        <img src="code.php" alt="看不清楚，换一张" style="cursor: pointer;" onclick="javascript:newgdcode(this,this.src);"><br>
            <form action="Codeshtml.php" method="post">
                username:<input type="text" name="username" size="19"><br>
                password:<input type="password" name="password" size="20"><br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                code:<input type="text" name="code" id="code" size="4"  value="">
                <input type="submit" name="submit" id="submit" value="提交">
            </form>

    </body>
</html>
